//
//  UIImage+ZWScale.m
//  kuaiyi
//
//  Created by flyiron on 16/5/9.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "UIImage+ZWScale.h"

@implementation UIImage (ZWScale)
- (UIImage *)scaleImageWithWidth:(CGFloat)width {
    if (width >= self.size.width) {
        return self;
    }
    
    CGFloat height = width/self.size.width * self.size.height;
    CGRect rect = CGRectMake(0, 0, width, height);
    UIGraphicsBeginImageContext(rect.size);
    [self drawInRect:rect];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
    
}

@end
